import { fromJS } from 'immutable'
import * as constants from './constants'

const defaultState = fromJS({
  topicList:[],
  list:[],
  imgList:[],
  writerList:[]
})

export default (state = defaultState, action) => {
  switch (action.type) {
    case constants.INIT_HOME_LIST_INFO:
      return state.merge({
        topicList: fromJS(action.topicList),
        list: fromJS(action.list),
        imgList: fromJS(action.imgList),
        writerList: fromJS(action.writerList)
      })
    case constants.ADD_HOME_LIST_LIST:
      return state.merge({
        list: state.get('list').concat(fromJS(action.list))
      })
    default:
      return state;
  }
}